package com.shujia.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo06Filter {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setMaster("local")
    conf.setAppName(this.getClass.getSimpleName.replace("$", ""))
    val sc = new SparkContext(conf)

    // filter：转换算子，可以过滤数据
    val stuRDD: RDD[String] = sc.textFile("spark/data/stu/students.txt")

    // 过滤出理科班的学生
    stuRDD
      .filter(line=>line.split(",")(4).startsWith("理科"))
      .foreach(println)

  }

}
